package servlets;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import sessionBeans.GestionContactLocal;

/**
 * Servlet implementation class DeleteContactServlet
 */
public class DeleteContactServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@EJB(name = "ContactBeanEntity", beanInterface = GestionContactLocal.class)
	GestionContactLocal daoContact;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public DeleteContactServlet() {
		super();

	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		try {

			daoContact.delete(Integer.parseInt(request.getParameter("id")));
			RequestDispatcher dispatcher = request
					.getRequestDispatcher("SearchContacts");

			dispatcher.forward(request, response);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
